﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using ECCSystem.BizRule;
using log4net;

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]	
namespace ECCSystem
{

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        //Temp,initialize operator
        

        static void Main()
        {
            //Application.Run(new frm_Ext_RelyPaper());
            //return;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //connect DB
			ReadXml();
            BizRule.ClsCommon objCommon = new ECCSystem.BizRule.ClsCommon();
            if (objCommon.ConnectDBServer() == false)
            {
                MessageBox.Show("DataBase connection failed!");
                return;
            }
            ExtUtility.logger = LogManager.Exists("FindBug");
            ECC_EXT_HttpLib.OnlineCheck.logger = LogManager.Exists("FindBug");
            Application.Run(new frmLogon());
        }

		#region "ReadXml"
		private static void ReadXml()
		{
			XmlDocument xd = new XmlDocument();
			string str = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
			xd.Load(str + "xmlSet.xml");
			XmlNode node = xd.SelectSingleNode("//DB");
			int nodesCount = node.ChildNodes.Count;
			for (int i = 0; i < nodesCount; i++)
			{

				string name = node.ChildNodes[i].LocalName;
				if ("Connection".Equals(name))
				{
					if (node.ChildNodes[i].InnerText == null)
					{

					}
					else
					{
						ClsCommon.gStrConnectionDB = node.ChildNodes[i].InnerText;
					}
				}

				if ("Time".Equals(name))
				{
					if (node.ChildNodes[i].InnerText == null)
					{

					}
					else
					{
						ClsCommon.gIntTime = Convert.ToInt32(node.ChildNodes[i].InnerText);
					}

				}
			}
		}
		#endregion
    }
}